const Koa = require("koa");
const route = require("koa-route");
const app = new Koa();

// 定义路由处理函数
const user = ctx => {
  ctx.body = [
    { name: "孙悟空", age: 18 },
    { name: "猪八戒", age: 28 },
    { name: "白龙马", age: 8 },
  ];
};

const about = ctx => {
  ctx.body = "About Page";
};

// 设置路由
app.use(route.get("/user", user));
app.use(route.get("/about", about));

// 启动服务器
app.listen(3000, () => {
  console.log("Server is running on http://localhost:3000");
});
